import request from '../../../utils/request'
Page({

    /**
     * 页面的初始数据
     */
    data: {
        searchContent: '', 
        searchList:'',
        index:0
    },
    async getSearchList(){
    let searchListData = await request('/search', {keywords: this.data.searchContent, limit: 15});
    this.setData({
        searchList: searchListData.result.songs
    })
    console.log(this.data.searchList);
  },

  toSongDetail(event){
    let {song, index} = event.currentTarget.dataset;
    this.setData({
      index
    })
    // 路由跳转传参： query参数
    wx.navigateTo({
      // 不能直接将song对象作为参数传递，长度过长，会被自动截取掉
      // url: '/pages/songDetail/songDetail?songPackage=' + JSON.stringify(songPackage)
      url: '/songPackage/pages/songDetail/songDetail?musicId=' + song.id
    })
  },

    onLoad: function (options) {
        let musicName = options.musicName;
        this.setData({
            searchContent:musicName
        })
        this.getSearchList()
    } ,

    ToMvList(e){
      const {mvid}=e.currentTarget.dataset
        // console.log(mvid);
        wx.navigateTo({
          url: '/songPackage/pages/Mvlist/Mvlist?mvid=' + mvid
        })
      // 路由跳转传参： query参数
    }

})